#include "../Core/IResource.h"
#include "../Core/ResourceManager.h"
#include "../Debug/Logger.h"

namespace epix {

IResource::IResource(const char *name) : _refCount(1)
{
    _name = name;
    ResourceManager::instance()->add(this);
}

IResource::~IResource()
{
}

int IResource::addRef()
{
    return ++_refCount;
}

int IResource::release()
{
    int count = --_refCount;
    if(_refCount == 0)
    {
		ResourceManager::instance()->remove(_name);
		delete this;
	}
    return count;
}

const std::string &IResource::getName() const
{
    return _name;
}

}

